package renshi.db.service;

import java.sql.*;

public class DbUtil {
     private Connection cn=null;
     public Connection getConn(){
     String url="jdbc:mysql://localhost/person";
    	 try{
    		Class.forName("org.gjt.mm.mysql.Driver");
    		
    		cn=DriverManager.getConnection(url,"root","root");
    	 }catch(ClassNotFoundException e){
    		 e.printStackTrace();
    	//	 System.out.print("����ʧ��");
    	 }catch(SQLException e){
    		 e.printStackTrace();
    	 }
    	 return cn;
     }
     
     public void closeConn(){
    	 try{
    		 if(cn!=null)
    			 cn.close();
    	//	 System.out.println("���ӳɹ�");
    	 }catch(SQLException e){
    		 e.printStackTrace();
    	 }
     }
}

